PHP_ARG_ENABLE(
	[evilworlds], [for evilworlds], 
	[AS_HELP_STRING([--enable-evilworlds], [enable evilworlds (default is no)])]
)

AC_ARG_ENABLE(
	[debug], 
	[AS_HELP_STRING([--enable-debug], [enable debug (default is no)])], 
	[debug_mode=yes], [debug_mode=no]
)

if test "${debug_mode}" = "yes"; then
	CFLAGS="$CFLAGS -g -std=c++11 -Wall "
	CPPFLAGS="$CPPFLAGS -g -std=c++11 -Wall "
	AC_DEFINE(DEBUG, 1, [Debug mode])
else
	CFLAGS="$CFLAGS -Ofast -march=native -std=c++11 "
	CPPFLAGS="$CPPFLAGS -Ofast -march=native -std=c++11 "
fi

# mysqlclient
PHP_ADD_INCLUDE(/usr/include/mysql)
if test "$enable_maintainer_zts" = "yes"; then # thread safe
	PHP_ADD_LIBRARY(mysqlclient_r, 1, EVILWORLDS_SHARED_LIBADD)
else
	PHP_ADD_LIBRARY(mysqlclient, 1, EVILWORLDS_SHARED_LIBADD)
fi

PHP_SUBST(EVILWORLDS_SHARED_LIBADD)
PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++, 1, EVILWORLDS_SHARED_LIBADD)

if test "${PHP_EVILWORLDS}" != "no"; then
PHP_NEW_EXTENSION(evilworlds, \
	src/php_evilworlds.cpp \
	src/hash.cpp \
	src/Text/TextPreprocessor.cpp \
	src/Text/Url.cpp, \
$ext_shared)
fi
